#include <string>
#include <algorithm>

#include "lines_provider.h"
#include "Line.h"

lines_provider::lines_provider()
{
	setLines();
}

void lines_provider::setLines()
{
	Line* l = new Line(1, "Red", 1);
	lines.push_back(l);
	l = new Line(2, "Blue", 2);
	lines.push_back(l);
	l = new Line(3, "Green", 3);
	lines.push_back(l);
	l = new Line(4, "Orange", 4);
	lines.push_back(l);
	l = new Line(5, "Purple", 5);
	lines.push_back(l);
}

lines_provider::~lines_provider()
{
}

Line*
lines_provider::getLine(int l)
{
	Line* line = NULL;
	for(int i = 0; i < lines.size(); i++)
	{
		if(lines[i]->getNumber() == l) {
			line = lines[i];
			break;
		}
	}
	return line;

}

Line*
lines_provider::getLine(std::string l)
{
	Line* line = NULL;
	for(int i = 0; i < lines.size(); i++)
	{
		if(lines[i]->getName() == l) {
			line = lines[i];
			break;
		}
	}
	return line;

}

std::vector<Line*>
lines_provider::getLines()
{
	return this->lines;
}

